﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using AACalc.ViewModels;
using AACalc.Models;

namespace AACalc
{
    public partial class SheetPage : PhoneApplicationPage
    {
        public SheetPage()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            var mode = NavigationContext.QueryString["mode"];

            if (mode != null)
            {
                if (mode == "recent")
                {
                    this.DataContext = App.ViewModel.Recent;
                }
            }
            base.OnNavigatedTo(e);
        }

        private void Grid_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var currentAttendee = this.lstAttendees.SelectedItem as Attendee;
            App.ViewModel.CurrentEditAttendee = new AttendeeEditorDataModel
            {
                Name = currentAttendee.Name,
                Payed = currentAttendee.AlreadyPay.ToString("n")
            };

            this.NavigationService.Navigate(new Uri("/AttendeeEditPage.xaml", UriKind.RelativeOrAbsolute));
        }
    }
}
